package com.javapda.c328r.util;

import gnu.io.CommPortIdentifier;

import java.util.LinkedHashMap;
import java.util.Map;

abstract public class PortTypeUtil {

	public static Map<String, Integer> getPortTypes() {
		Map<String, Integer> map = new LinkedHashMap<String, Integer>();
		map.put("SERIAL PORT", CommPortIdentifier.PORT_SERIAL);
		map.put("PARALLEL PORT", CommPortIdentifier.PORT_PARALLEL);
		map.put("I2C PORT", CommPortIdentifier.PORT_I2C);
		map.put("RS485 PORT", CommPortIdentifier.PORT_RS485);
		map.put("RAW PORT", CommPortIdentifier.PORT_RAW);
		return map;
	}

	public static String getPortTypeName(int portType) {
		switch (portType) {
		case CommPortIdentifier.PORT_I2C:
			return "I2C";
		case CommPortIdentifier.PORT_PARALLEL:
			return "Parallel";
		case CommPortIdentifier.PORT_RAW:
			return "Raw";
		case CommPortIdentifier.PORT_RS485:
			return "RS485";
		case CommPortIdentifier.PORT_SERIAL:
			return "Serial";
		default:
			return "unknown type";
		}
	}

}
